set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR aarch64)

# 替换为你实际交叉编译工具链路径
set(CMAKE_C_COMPILER /home/xhz/Lemon/Lemon-3588-SDK-Linux-V1.0/prebuilts/gcc/linux-x86/aarch64/gcc-arm-10.3-2021.07-x86_64-aarch64-none-linux-gnu/bin/aarch64-none-linux-gnu-gcc)
set(CMAKE_CXX_COMPILER /home/xhz/Lemon/Lemon-3588-SDK-Linux-V1.0/prebuilts/gcc/linux-x86/aarch64/gcc-arm-10.3-2021.07-x86_64-aarch64-none-linux-gnu/bin/aarch64-none-linux-gnu-g++)

# # 可选：sysroot 路径（推荐）
# set(CMAKE_SYSROOT /home/xhz/projects/env/sysroot)
# set(CMAKE_FIND_ROOT_PATH ${CMAKE_SYSROOT})

# set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
# set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)

# # 显式添加库文件路径，避免链接器找不到 crt1.o 等
# set(CMAKE_C_FLAGS_INIT "-L${CMAKE_SYSROOT}/usr/lib/aarch64-linux-gnu")
# set(CMAKE_EXE_LINKER_FLAGS_INIT "-L${CMAKE_SYSROOT}/usr/lib/aarch64-linux-gnu")

# # 显式告诉链接器“启动文件”的位置（重点）
# set(CMAKE_EXE_LINKER_FLAGS_INIT "-Wl,-rpath-link=${CMAKE_SYSROOT}/usr/lib/aarch64-linux-gnu -L${CMAKE_SYSROOT}/usr/lib/aarch64-linux-gnu")
# # 添加 sysroot 下的库路径作为补充，而不是替代
# set(CMAKE_C_FLAGS "-I/home/xhz/projects/env/sysroot/usr/include/aarch64-linux-gnu")
# set(CMAKE_CXX_FLAGS "-I/home/xhz/projects/env/sysroot/usr/include/aarch64-linux-gnu")
# set(CMAKE_EXE_LINKER_FLAGS "-Wl,-rpath-link=/home/xhz/projects/env/sysroot/usr/lib/aarch64-linux-gnu -L/home/xhz/projects/env/sysroot/usr/lib/aarch64-linux-gnu")

# set(CMAKE_CXX_FLAGS "-nostdlib -L${CMAKE_SYSROOT}/usr/lib/aarch64-linux-gnu -I${CMAKE_SYSROOT}/usr/include/c++/10 -I${CMAKE_SYSROOT}/usr/include/aarch64-linux-gnu")
# set(CMAKE_EXE_LINKER_FLAGS "-L${CMAKE_SYSROOT}/usr/lib/aarch64-linux-gnu -Wl,-rpath-link=${CMAKE_SYSROOT}/usr/lib/aarch64-linux-gnu")